Disclaimer: The code to this program has been inspired from various sources that I have found on google